package com.whmskj.xjlhbc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.whmskj.xjlhbc.domain.Js05dVarietyMaintenance;
import com.whmskj.xjlhbc.domain.ScProductionOrders;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface ScProductionOrdersMapper extends BaseMapper<ScProductionOrders> {
    /**
     * 根据关键字查询
     * @param keyword
     * @return
     */
    List<Js05dVarietyMaintenance> selectByKeyword(String keyword);
    List<Js05dVarietyMaintenance> selectByKeywordScz(String keyword);
    /**
     * 新增订单
     * @param order
     * @return
     */
    int insertOrder(ScProductionOrders order);

    /**
     * 根据订单编号查询
     * @param orderNumber
     * @return
     */
    ScProductionOrders selectByOrderNumber(String orderNumber);

    /**
     * 删除订单
     * @param orderNumber
     * @return
     */
    int deleteByOrderNumber(String orderNumber);

    /**
     * 修改订单
     * @param order
     * @return
     */
    int updateByOrderNumber(ScProductionOrders order);

    /**
     * 统计订单状态
     * @return
     */
    @MapKey("orderStatus")
    List<Map<String, Object>> countByStatus();

    /**
     * 统计未完成生产和已过交付期订单
     * @return
     */
    @MapKey("statType")
    Map<String, Object> countUncompletedAndOverdue();

    /**
     * 按月统计销售下单和完成订单
     * @param months
     * @return
     */
    @MapKey("month")
    List<Map<String, Object>> countByMonth(@Param("months") int months);
}
